//
//  AlermModel.m
//  Lightthings
//
//  Created by Hero on 2024/11/15.
//

#import "AlermModel.h"

@implementation AlermModel
- (instancetype)initWithString:(NSString *)string {
    if (self = [super init]) {
        self.alermID = strtoll([[NSString stringWithFormat:@"0x%@",[string substringWithRange:NSMakeRange(0, 2)]] UTF8String], 0, 16);
        self.isOpen = strtoll([[NSString stringWithFormat:@"0x%@",[string substringWithRange:NSMakeRange(2, 2)]] UTF8String], 0, 16);
        self.alert_H = strtoll([[NSString stringWithFormat:@"0x%@",[string substringWithRange:NSMakeRange(6, 2)]] UTF8String], 0, 16);
        self.alert_M = strtoll([[NSString stringWithFormat:@"0x%@",[string substringWithRange:NSMakeRange(8, 2)]] UTF8String], 0, 16);
        NSString * s = [NSString stringWithFormat:@"%lld",strtoll([[NSString stringWithFormat:@"0x%@",[string substringWithRange:NSMakeRange(4, 2)]] UTF8String], 0, 16)];
        self.repeat = [SWTool decimalToBinary:s];
        
    }
    return self;
}

@end
